import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;


public class Background {
	
	private double dk = 0;
	private int k=0;
	private BufferedImage background;
		
		public Background(Dimension dim) {
			background = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB);
			Graphics2D gb = (Graphics2D)background.getGraphics();
			gb.setColor(Color.WHITE);
			
			for (int i=0;i<2000;i++){
				
				gb.fillOval((int)(Math.random()*dim.width), (int)(Math.random()*dim.height), (int)(Math.random()*3), (int)(Math.random()*3));
			}						
		}

		public void draw(Graphics g) {
			k= (int) dk;
			g.drawImage(background, 0, 0, background.getWidth(), k, 0, background.getHeight()-k, background.getWidth(), background.getHeight(), null);
			g.drawImage(background, 0, k, background.getWidth(), background.getHeight(), 0, 0, background.getWidth(), background.getHeight()-k, null);
			dk+=0.1;
			if (dk >= background.getHeight()){
				dk=0;
			}
		}
		
}
